/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    ap-northeast-1 = 'dg.aliyuncs.com',
    ap-northeast-2-pop = 'dg.aliyuncs.com',
    ap-south-1 = 'dg.aliyuncs.com',
    ap-southeast-1 = 'dg.aliyuncs.com',
    ap-southeast-2 = 'dg.aliyuncs.com',
    ap-southeast-3 = 'dg.aliyuncs.com',
    ap-southeast-5 = 'dg.aliyuncs.com',
    cn-beijing = 'dg.aliyuncs.com',
    cn-beijing-finance-1 = 'dg.aliyuncs.com',
    cn-beijing-finance-pop = 'dg.aliyuncs.com',
    cn-beijing-gov-1 = 'dg.aliyuncs.com',
    cn-beijing-nu16-b01 = 'dg.aliyuncs.com',
    cn-chengdu = 'dg.aliyuncs.com',
    cn-edge-1 = 'dg.aliyuncs.com',
    cn-fujian = 'dg.aliyuncs.com',
    cn-haidian-cm12-c01 = 'dg.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'dg.aliyuncs.com',
    cn-hangzhou-finance = 'dg.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'dg.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'dg.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'dg.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'dg.aliyuncs.com',
    cn-hangzhou-test-306 = 'dg.aliyuncs.com',
    cn-hongkong = 'dg.aliyuncs.com',
    cn-hongkong-finance-pop = 'dg.aliyuncs.com',
    cn-huhehaote = 'dg.aliyuncs.com',
    cn-north-2-gov-1 = 'dg.aliyuncs.com',
    cn-qingdao = 'dg.aliyuncs.com',
    cn-qingdao-nebula = 'dg.aliyuncs.com',
    cn-shanghai = 'dg.aliyuncs.com',
    cn-shanghai-et15-b01 = 'dg.aliyuncs.com',
    cn-shanghai-et2-b01 = 'dg.aliyuncs.com',
    cn-shanghai-finance-1 = 'dg.aliyuncs.com',
    cn-shanghai-inner = 'dg.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'dg.aliyuncs.com',
    cn-shenzhen = 'dg.aliyuncs.com',
    cn-shenzhen-finance-1 = 'dg.aliyuncs.com',
    cn-shenzhen-inner = 'dg.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'dg.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'dg.aliyuncs.com',
    cn-wuhan = 'dg.aliyuncs.com',
    cn-yushanfang = 'dg.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'dg.aliyuncs.com',
    cn-zhangjiakou = 'dg.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'dg.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'dg.aliyuncs.com',
    eu-central-1 = 'dg.aliyuncs.com',
    eu-west-1 = 'dg.aliyuncs.com',
    eu-west-1-oxs = 'dg.aliyuncs.com',
    me-east-1 = 'dg.aliyuncs.com',
    rus-west-1-pop = 'dg.aliyuncs.com',
    us-east-1 = 'dg.aliyuncs.com',
    us-west-1 = 'dg.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('dg', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AddDatabaseRequest {
  clientToken?: string(name='ClientToken', example='ETnLKlblzczshOTUbOCzxxxx'),
  dbDescription?: string(name='DbDescription'),
  dbName?: string(name='DbName', example='db_test'),
  dbPassword?: string(name='DbPassword', example='password'),
  dbType?: string(name='DbType', example='MySQL'),
  dbUserName?: string(name='DbUserName', example='dg_test'),
  gatewayId?: string(name='GatewayId', example='dg-yhss6sdla****'),
  host?: string(name='Host', example='11.*.*.109'),
  port?: int32(name='Port', example='3440'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
}

model AddDatabaseResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='test_data'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='41916DEB-F62D-41FA-AB53-FC61D795BC88'),
  success?: boolean(name='Success', example='true'),
}

model AddDatabaseResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddDatabaseResponseBody(name='body'),
}

async function addDatabaseWithOptions(request: AddDatabaseRequest, runtime: Util.RuntimeOptions): AddDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.dbDescription)) {
    body['DbDescription'] = request.dbDescription;
  }
  if (!Util.isUnset(request.dbName)) {
    body['DbName'] = request.dbName;
  }
  if (!Util.isUnset(request.dbPassword)) {
    body['DbPassword'] = request.dbPassword;
  }
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.dbUserName)) {
    body['DbUserName'] = request.dbUserName;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddDatabase',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addDatabase(request: AddDatabaseRequest): AddDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return addDatabaseWithOptions(request, runtime);
}

model AddDatabaseListRequest {
  clientToken?: string(name='ClientToken', example='ETnLKlblzczshOTUbOCzxxxx'),
  databaseString?: string(name='DatabaseString', example='[{"host":"127.0.0.1","port":"3306","gatewayId":"dg-xsdasdasdasdasd"}]'),
}

model AddDatabaseListResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Error'),
  requestId?: string(name='RequestId', example='ABCD-1234'),
  success?: boolean(name='Success', example='true'),
}

model AddDatabaseListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddDatabaseListResponseBody(name='body'),
}

async function addDatabaseListWithOptions(request: AddDatabaseListRequest, runtime: Util.RuntimeOptions): AddDatabaseListResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.databaseString)) {
    body['DatabaseString'] = request.databaseString;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddDatabaseList',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addDatabaseList(request: AddDatabaseListRequest): AddDatabaseListResponse {
  var runtime = new Util.RuntimeOptions{};
  return addDatabaseListWithOptions(request, runtime);
}

model ConnectDatabaseRequest {
  dbName?: string(name='DbName', example='db_name'),
  dbPassword?: string(name='DbPassword', example='password'),
  dbType?: string(name='DbType', example='MySQL'),
  dbUserName?: string(name='DbUserName', example='dg_test'),
  gatewayId?: string(name='GatewayId', example='dg-yhss6sdlaff****'),
  host?: string(name='Host', example='11.163.23.109'),
  port?: int32(name='Port', example='3440'),
}

model ConnectDatabaseResponseBody = {
  code?: string(name='Code', example='OK'),
  data?: string(name='Data', example='test_data'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='EAF2AA07-860D-43DA-BEE8-1E43AAE024DG'),
  success?: boolean(name='Success', example='true'),
}

model ConnectDatabaseResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ConnectDatabaseResponseBody(name='body'),
}

async function connectDatabaseWithOptions(request: ConnectDatabaseRequest, runtime: Util.RuntimeOptions): ConnectDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dbName)) {
    body['DbName'] = request.dbName;
  }
  if (!Util.isUnset(request.dbPassword)) {
    body['DbPassword'] = request.dbPassword;
  }
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.dbUserName)) {
    body['DbUserName'] = request.dbUserName;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConnectDatabase',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function connectDatabase(request: ConnectDatabaseRequest): ConnectDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return connectDatabaseWithOptions(request, runtime);
}

model CreateDatabaseAccessPointRequest {
  clientToken?: string(name='ClientToken', example='ETnLKlblzczshOTUbOCzxxxx'),
  dbInstanceId?: string(name='DbInstanceId', example='dg-db-abcd1234'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  vSwitchId?: string(name='VSwitchId', example='vsw-123abcd'),
  vpcAZone?: string(name='VpcAZone', example='cn-hangzhou-i'),
  vpcId?: string(name='VpcId', example='vpc-123abcd'),
  vpcRegionId?: string(name='VpcRegionId', example='cn-hangzhou'),
}

model CreateDatabaseAccessPointResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='test_data'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='41916DEB-F62D-41FA-AB53-FC61D795BC66'),
  success?: boolean(name='Success', example='true'),
}

model CreateDatabaseAccessPointResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateDatabaseAccessPointResponseBody(name='body'),
}

async function createDatabaseAccessPointWithOptions(request: CreateDatabaseAccessPointRequest, runtime: Util.RuntimeOptions): CreateDatabaseAccessPointResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.dbInstanceId)) {
    body['DbInstanceId'] = request.dbInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.vSwitchId)) {
    body['VSwitchId'] = request.vSwitchId;
  }
  if (!Util.isUnset(request.vpcAZone)) {
    body['VpcAZone'] = request.vpcAZone;
  }
  if (!Util.isUnset(request.vpcId)) {
    body['VpcId'] = request.vpcId;
  }
  if (!Util.isUnset(request.vpcRegionId)) {
    body['VpcRegionId'] = request.vpcRegionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateDatabaseAccessPoint',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createDatabaseAccessPoint(request: CreateDatabaseAccessPointRequest): CreateDatabaseAccessPointResponse {
  var runtime = new Util.RuntimeOptions{};
  return createDatabaseAccessPointWithOptions(request, runtime);
}

model CreateGatewayRequest {
  gatewayDesc?: string(name='GatewayDesc'),
  gatewayName?: string(name='GatewayName'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
}

model CreateGatewayResponseBody = {
  code?: string(name='Code', example='OK'),
  data?: string(name='Data', example='dg-yhss6sdlaff****'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId', example='A7D17E3E-358C-4A80-986C-F6C3B048AD17'),
  success?: boolean(name='Success', example='true'),
}

model CreateGatewayResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateGatewayResponseBody(name='body'),
}

async function createGatewayWithOptions(request: CreateGatewayRequest, runtime: Util.RuntimeOptions): CreateGatewayResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayDesc)) {
    body['GatewayDesc'] = request.gatewayDesc;
  }
  if (!Util.isUnset(request.gatewayName)) {
    body['GatewayName'] = request.gatewayName;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateGateway',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createGateway(request: CreateGatewayRequest): CreateGatewayResponse {
  var runtime = new Util.RuntimeOptions{};
  return createGatewayWithOptions(request, runtime);
}

model CreateGatewayVerifyCodeRequest {
  gatewayId?: string(name='GatewayId', example='dg-yhss6sdlaff****'),
}

model CreateGatewayVerifyCodeResponseBody = {
  code?: string(name='Code', example='SYSTEM_ERR'),
  data?: string(name='Data', example='O2emaiUwOqSakQhidbbvb4mu8Rpy****'),
  errorMsg?: string(name='ErrorMsg', example='Check parameter failure[User not match gateway].'),
  requestId?: string(name='RequestId', example='D31DB440-6025-57A6-841C-DD366F1B54C3'),
  success?: boolean(name='Success', example='true'),
}

model CreateGatewayVerifyCodeResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateGatewayVerifyCodeResponseBody(name='body'),
}

async function createGatewayVerifyCodeWithOptions(request: CreateGatewayVerifyCodeRequest, runtime: Util.RuntimeOptions): CreateGatewayVerifyCodeResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateGatewayVerifyCode',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createGatewayVerifyCode(request: CreateGatewayVerifyCodeRequest): CreateGatewayVerifyCodeResponse {
  var runtime = new Util.RuntimeOptions{};
  return createGatewayVerifyCodeWithOptions(request, runtime);
}

model DeleteDatabaseRequest {
  instanceId?: string(name='InstanceId', example='z8gw7qdjm36****'),
}

model DeleteDatabaseResponseBody = {
  code?: string(name='Code', example='OK'),
  data?: string(name='Data', example='2019-09-12T14:40:46'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId', example='CDDAAA07-D806-AG67-BEE8-1E43AAE024DC'),
  success?: boolean(name='Success', example='true'),
}

model DeleteDatabaseResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteDatabaseResponseBody(name='body'),
}

async function deleteDatabaseWithOptions(request: DeleteDatabaseRequest, runtime: Util.RuntimeOptions): DeleteDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteDatabase',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteDatabase(request: DeleteDatabaseRequest): DeleteDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteDatabaseWithOptions(request, runtime);
}

model DeleteDatabaseAccessPointRequest {
  dbInstanceId?: string(name='DbInstanceId', example='dg-db-abcd123'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  vSwitchId?: string(name='VSwitchId', example='vsw-123abcd'),
  vpcAZone?: string(name='VpcAZone', example='cn-hangzhou-i'),
  vpcId?: string(name='VpcId', example='vpc-123abcd'),
  vpcRegionId?: string(name='VpcRegionId', example='cn-hangzhou'),
}

model DeleteDatabaseAccessPointResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='41916DEB-F62D-41FA-AB53-FC61D795BC66'),
  success?: boolean(name='Success', example='true'),
}

model DeleteDatabaseAccessPointResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteDatabaseAccessPointResponseBody(name='body'),
}

async function deleteDatabaseAccessPointWithOptions(request: DeleteDatabaseAccessPointRequest, runtime: Util.RuntimeOptions): DeleteDatabaseAccessPointResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dbInstanceId)) {
    body['DbInstanceId'] = request.dbInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.vSwitchId)) {
    body['VSwitchId'] = request.vSwitchId;
  }
  if (!Util.isUnset(request.vpcAZone)) {
    body['VpcAZone'] = request.vpcAZone;
  }
  if (!Util.isUnset(request.vpcId)) {
    body['VpcId'] = request.vpcId;
  }
  if (!Util.isUnset(request.vpcRegionId)) {
    body['VpcRegionId'] = request.vpcRegionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteDatabaseAccessPoint',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteDatabaseAccessPoint(request: DeleteDatabaseAccessPointRequest): DeleteDatabaseAccessPointResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteDatabaseAccessPointWithOptions(request, runtime);
}

model DeleteGatewayRequest {
  gatewayId?: string(name='GatewayId', example='dg-9z57rbne******'),
}

model DeleteGatewayResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='60B7DF92-CC90-5166-9965-BCBE5F2911CD'),
  success?: boolean(name='Success', example='true'),
}

model DeleteGatewayResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteGatewayResponseBody(name='body'),
}

async function deleteGatewayWithOptions(request: DeleteGatewayRequest, runtime: Util.RuntimeOptions): DeleteGatewayResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteGateway',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteGateway(request: DeleteGatewayRequest): DeleteGatewayResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteGatewayWithOptions(request, runtime);
}

model DeleteGatewayInstanceRequest {
  gatewayId?: string(name='GatewayId', example='dg-123'),
  gatewayInstanceId?: string(name='GatewayInstanceId', example='dg-node-123'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
}

model DeleteGatewayInstanceResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Error'),
  requestId?: string(name='RequestId', example='41916DEB-F62D-41FA-AB53-FC61D795BC66'),
  success?: boolean(name='Success', example='true'),
}

model DeleteGatewayInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteGatewayInstanceResponseBody(name='body'),
}

async function deleteGatewayInstanceWithOptions(request: DeleteGatewayInstanceRequest, runtime: Util.RuntimeOptions): DeleteGatewayInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.gatewayInstanceId)) {
    body['GatewayInstanceId'] = request.gatewayInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteGatewayInstance',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteGatewayInstance(request: DeleteGatewayInstanceRequest): DeleteGatewayInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteGatewayInstanceWithOptions(request, runtime);
}

model DescribeRegionsRequest {
  regionId?: string(name='RegionId', example='cn-hangzhou'),
}

model DescribeRegionsResponseBody = {
  code?: string(name='Code', example='200'),
  errorMsg?: string(name='ErrorMsg', example='Error'),
  regions?: {
    region?: [ 
    {
      localName?: string(name='LocalName'),
      regionEndpoint?: string(name='RegionEndpoint', description='Region Endpoint。', example='dg.cn-hangzhou.aliyuncs.com'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
    }
  ](name='Region')
  }(name='Regions', description='Region'),
  requestId?: string(name='RequestId', example='41916DEB-F62D-41FA-AB53-FC61D795BC66'),
  success?: boolean(name='Success', example='true'),
}

model DescribeRegionsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeRegionsResponseBody(name='body'),
}

async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DescribeRegions',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model DownloadGatewayProgramRequest {
  dgVersion?: string(name='DgVersion'),
  userOS?: string(name='UserOS', example='your OS'),
}

model DownloadGatewayProgramResponseBody = {
  code?: string(name='Code', example='OK'),
  data?: string(name='Data', example='https://public-buk.oss-cn-hangzhou.aliyuncs.com/db-gateway-pkgs/gateway-daemon-pkgs/aliyun-db-gateway.tar.gz?Expires=xxx/YV56pzE%3D'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId', example='028D8614-5940-4BC4-86BB-428E115F27DC'),
  success?: boolean(name='Success', example='true'),
}

model DownloadGatewayProgramResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DownloadGatewayProgramResponseBody(name='body'),
}

async function downloadGatewayProgramWithOptions(request: DownloadGatewayProgramRequest, runtime: Util.RuntimeOptions): DownloadGatewayProgramResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dgVersion)) {
    body['DgVersion'] = request.dgVersion;
  }
  if (!Util.isUnset(request.userOS)) {
    body['UserOS'] = request.userOS;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DownloadGatewayProgram',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function downloadGatewayProgram(request: DownloadGatewayProgramRequest): DownloadGatewayProgramResponse {
  var runtime = new Util.RuntimeOptions{};
  return downloadGatewayProgramWithOptions(request, runtime);
}

model FindUserGatewayByIdRequest {
  gatewayId?: string(name='GatewayId', example='dg-yhss6sdlaff****'),
}

model FindUserGatewayByIdResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg', example='""'),
  requestId?: string(name='RequestId', example='31728E14-8164-49C3-928B-044E93B8A11E'),
  success?: boolean(name='Success', example='true'),
}

model FindUserGatewayByIdResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: FindUserGatewayByIdResponseBody(name='body'),
}

async function findUserGatewayByIdWithOptions(request: FindUserGatewayByIdRequest, runtime: Util.RuntimeOptions): FindUserGatewayByIdResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'FindUserGatewayById',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function findUserGatewayById(request: FindUserGatewayByIdRequest): FindUserGatewayByIdResponse {
  var runtime = new Util.RuntimeOptions{};
  return findUserGatewayByIdWithOptions(request, runtime);
}

model GetUserDatabasesRequest {
  dbType?: string(name='DbType', example='MySQL'),
  gatewayId?: string(name='GatewayId', example='dg-yhss6sdlaff****'),
  host?: string(name='Host', example='11.*.*.109'),
  instanceId?: string(name='InstanceId', example='db'),
  pageNumber?: string(name='PageNumber', example='1'),
  pageSize?: string(name='PageSize', example='10'),
  port?: int32(name='Port', example='3440'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  searchKey?: string(name='SearchKey'),
}

model GetUserDatabasesResponseBody = {
  code?: string(name='Code', example='OK'),
  count?: int32(name='Count', example='1'),
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId', example='951AE6AA-BFC5-4DD8-8CD6-DFD3D51E4170'),
  success?: string(name='Success', example='true'),
}

model GetUserDatabasesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetUserDatabasesResponseBody(name='body'),
}

async function getUserDatabasesWithOptions(request: GetUserDatabasesRequest, runtime: Util.RuntimeOptions): GetUserDatabasesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.searchKey)) {
    body['SearchKey'] = request.searchKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetUserDatabases',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getUserDatabases(request: GetUserDatabasesRequest): GetUserDatabasesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUserDatabasesWithOptions(request, runtime);
}

model GetUserGatewayInstancesRequest {
  gatewayId?: string(name='GatewayId', example='dg-7i09blz8i*******'),
}

model GetUserGatewayInstancesResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='[{\\"connectEndpointType\\":\\"INTERNET\\",\\"currentDaemonVersion\\":\\"3.0\\",\\"currentVersion\\":\\"3.0\\",\\"endPoint\\":\\"pub-cn-hangzhou.dg.aliyuncs.com\\",\\"gatewayId\\":\\"dg-7i09bl******\\",\\"gatewayInstanceId\\":\\"dg-node-IjtchHPSucZ******\\",\\"gatewayInstanceStatus\\":\\"STOPPED\\",\\"lastUpdateTime\\":\\"16124920*****\\",\\"localIP\\":\\"172.XX.XX.49\\",\\"message\\":\\"\\",\\"outputIP\\":\\"172.XX.XX.49\\"}]'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='4171E7B3-ED84-5882-90ED-924A08EDD414'),
  success?: boolean(name='Success', example='true'),
}

model GetUserGatewayInstancesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetUserGatewayInstancesResponseBody(name='body'),
}

async function getUserGatewayInstancesWithOptions(request: GetUserGatewayInstancesRequest, runtime: Util.RuntimeOptions): GetUserGatewayInstancesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetUserGatewayInstances',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getUserGatewayInstances(request: GetUserGatewayInstancesRequest): GetUserGatewayInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUserGatewayInstancesWithOptions(request, runtime);
}

model GetUserGatewaysRequest {
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='20'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  searchKey?: string(name='SearchKey', example='test'),
}

model GetUserGatewaysResponseBody = {
  code?: string(name='Code', example='200'),
  count?: int32(name='Count', example='15'),
  data?: string(name='Data', example='[{\\"creatorId\\":\\"\\",\\"dgVersion\\":\\"3\\",\\"exceptionMsg\\":\\"\\",\\"gatewayDesc\\":\\"test\\",\\"gatewayId\\":\\"dg-a55it25s******\\",\\"gatewayName\\":\\"shu**test\\",\\"numOfExceptionInstance\\":0,\\"numOfRunningInstance\\":0,\\"regionId\\":\\"cn-hangzhou\\",\\"status\\":\\"STOPPED\\",\\"userId\\":\\"140692647******\\"}]'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='E68F1794-354B-4F18-AA6D-1F00353E632E'),
  success?: boolean(name='Success', example='true'),
}

model GetUserGatewaysResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetUserGatewaysResponseBody(name='body'),
}

async function getUserGatewaysWithOptions(request: GetUserGatewaysRequest, runtime: Util.RuntimeOptions): GetUserGatewaysResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.searchKey)) {
    body['SearchKey'] = request.searchKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetUserGateways',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getUserGateways(request: GetUserGatewaysRequest): GetUserGatewaysResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUserGatewaysWithOptions(request, runtime);
}

model ListDatabaseAccessPointRequest {
  dbInstanceId?: string(name='DbInstanceId', example='dg-db-123'),
  gatewayId?: string(name='GatewayId', example='dg-123'),
  host?: string(name='Host', example='127.XX.XX.1'),
  pageNumber?: string(name='PageNumber', example='1'),
  pageSize?: string(name='PageSize', example='20'),
  port?: int32(name='Port', example='3306'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  searchKey?: string(name='SearchKey', example='dg-123'),
  vpcId?: string(name='VpcId', example='vpc-123'),
}

model ListDatabaseAccessPointResponseBody = {
  code?: string(name='Code', example='200'),
  count?: int32(name='Count', example='1'),
  data?: string(name='Data', example='[{\\"accessAddr\\":\\"172.XX.XX.205\\",\\"accessPort\\":450**,\\"dbInstanceId\\":\\"dg--0gt663453******\\",\\"gmtCreate\\":16426*******,\\"gmtModified\\":1642649******,\\"routerId\\":\\"cn-hangzhou\\",\\"vpcAzoneId\\":\\"cn-hangzhou-h\\",\\"vpcId\\":\\"vpc-bp13h7uzhul******\\",\\"vswitchId\\":\\"vsw-bp1syh8v******\\"}]'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='08897339-B531-56EE-AB7E-71E69DFDEBDA'),
  success?: string(name='Success', example='true'),
}

model ListDatabaseAccessPointResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListDatabaseAccessPointResponseBody(name='body'),
}

async function listDatabaseAccessPointWithOptions(request: ListDatabaseAccessPointRequest, runtime: Util.RuntimeOptions): ListDatabaseAccessPointResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dbInstanceId)) {
    body['DbInstanceId'] = request.dbInstanceId;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.searchKey)) {
    body['SearchKey'] = request.searchKey;
  }
  if (!Util.isUnset(request.vpcId)) {
    body['VpcId'] = request.vpcId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListDatabaseAccessPoint',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listDatabaseAccessPoint(request: ListDatabaseAccessPointRequest): ListDatabaseAccessPointResponse {
  var runtime = new Util.RuntimeOptions{};
  return listDatabaseAccessPointWithOptions(request, runtime);
}

model ModifyDatabaseRequest {
  dbDescription?: string(name='DbDescription'),
  dbName?: string(name='DbName', example='db_test'),
  dbPassword?: string(name='DbPassword', example='password'),
  dbType?: string(name='DbType', example='MySQL'),
  dbUserName?: string(name='DbUserName', example='dg_test'),
  host?: string(name='Host', example='11.*.*.109'),
  instanceId?: string(name='InstanceId', example='db'),
  port?: int32(name='Port', example='3440'),
}

model ModifyDatabaseResponseBody = {
  code?: string(name='Code', example='OK'),
  data?: string(name='Data', example='2019-09-12T14:40:46'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='EAF2AA07-860D-43DA-BEE8-1E43AAE024ED'),
  success?: boolean(name='Success', example='true'),
}

model ModifyDatabaseResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ModifyDatabaseResponseBody(name='body'),
}

async function modifyDatabaseWithOptions(request: ModifyDatabaseRequest, runtime: Util.RuntimeOptions): ModifyDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dbDescription)) {
    body['DbDescription'] = request.dbDescription;
  }
  if (!Util.isUnset(request.dbName)) {
    body['DbName'] = request.dbName;
  }
  if (!Util.isUnset(request.dbPassword)) {
    body['DbPassword'] = request.dbPassword;
  }
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.dbUserName)) {
    body['DbUserName'] = request.dbUserName;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ModifyDatabase',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function modifyDatabase(request: ModifyDatabaseRequest): ModifyDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyDatabaseWithOptions(request, runtime);
}

model ModifyGatewayRequest {
  gatewayDesc?: string(name='GatewayDesc'),
  gatewayId?: string(name='GatewayId', example='dg-yhss6sdlaff****'),
  gatewayName?: string(name='GatewayName', example='gateway_name'),
}

model ModifyGatewayResponseBody = {
  code?: string(name='Code', example='OK'),
  data?: string(name='Data', example='data_test'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='CDDAAA07-D806-AG67-BEE8-1E43AAE024DC'),
  success?: boolean(name='Success', example='true'),
}

model ModifyGatewayResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ModifyGatewayResponseBody(name='body'),
}

async function modifyGatewayWithOptions(request: ModifyGatewayRequest, runtime: Util.RuntimeOptions): ModifyGatewayResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayDesc)) {
    body['GatewayDesc'] = request.gatewayDesc;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.gatewayName)) {
    body['GatewayName'] = request.gatewayName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ModifyGateway',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function modifyGateway(request: ModifyGatewayRequest): ModifyGatewayResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyGatewayWithOptions(request, runtime);
}

model RetryDatabaseRequest {
  clientToken?: string(name='ClientToken', example='ETnLKlblzczshOTUbOCzxxxx'),
  dbDescription?: string(name='DbDescription', example='123'),
  dbName?: string(name='DbName', example='abcd'),
  dbPassword?: string(name='DbPassword', example='123'),
  dbType?: string(name='DbType', example='MySQL'),
  dbUserName?: string(name='DbUserName', example='abcd'),
  gatewayId?: string(name='GatewayId', example='dg-yhss6sdlaff****'),
  host?: string(name='Host', example='127.0.0.1'),
  port?: int32(name='Port', example='3306'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
}

model RetryDatabaseResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Error'),
  requestId?: string(name='RequestId', example='CDDAAA07-D806-AG67-BEE8-1E43AAE024DD'),
  success?: boolean(name='Success', example='true'),
}

model RetryDatabaseResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RetryDatabaseResponseBody(name='body'),
}

async function retryDatabaseWithOptions(request: RetryDatabaseRequest, runtime: Util.RuntimeOptions): RetryDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.dbDescription)) {
    body['DbDescription'] = request.dbDescription;
  }
  if (!Util.isUnset(request.dbName)) {
    body['DbName'] = request.dbName;
  }
  if (!Util.isUnset(request.dbPassword)) {
    body['DbPassword'] = request.dbPassword;
  }
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.dbUserName)) {
    body['DbUserName'] = request.dbUserName;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RetryDatabase',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function retryDatabase(request: RetryDatabaseRequest): RetryDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return retryDatabaseWithOptions(request, runtime);
}

model StopGatewayRequest {
  gatewayId?: string(name='GatewayId', example='dg-yhss6sdlaff****'),
  gatewayInstanceId?: string(name='GatewayInstanceId', example='dg-node-123'),
}

model StopGatewayResponseBody = {
  code?: string(name='Code', example='OK'),
  data?: string(name='Data', example='test_data'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='CDDAAA07-D806-AG67-BEE8-1E43AAE024DE'),
  success?: boolean(name='Success', example='true'),
}

model StopGatewayResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: StopGatewayResponseBody(name='body'),
}

async function stopGatewayWithOptions(request: StopGatewayRequest, runtime: Util.RuntimeOptions): StopGatewayResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.gatewayInstanceId)) {
    body['GatewayInstanceId'] = request.gatewayInstanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'StopGateway',
    version = '2019-03-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function stopGateway(request: StopGatewayRequest): StopGatewayResponse {
  var runtime = new Util.RuntimeOptions{};
  return stopGatewayWithOptions(request, runtime);
}

